package com.openbravo.data.loader;

import com.openbravo.basic.BasicException;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseSentence
  implements SentenceList, SentenceFind, SentenceExec
{
  public abstract DataResultSet openExec(Object paramObject)
    throws BasicException;

  public abstract DataResultSet moreResults()
    throws BasicException;

  public abstract void closeExec()
    throws BasicException;

  public final int exec()
    throws BasicException
  {
    return exec((Object)null);
  }

  public final int exec(Object[] paramArrayOfObject)
    throws BasicException
  {
    return exec((Object)paramArrayOfObject);
  }

  public final int exec(Object paramObject)
    throws BasicException
  {
    DataResultSet localDataResultSet = openExec(paramObject);
    if (localDataResultSet == null)
      throw new BasicException(LocalRes.getIntString("exception.noupdatecount"));
    //updateCount com.openbravo.data.loader.SentenceUpdateResultSet@1073efd
    int i = localDataResultSet.updateCount();
    localDataResultSet.close();
    closeExec();
    return i;
  }

  public final List list()
    throws BasicException
  {
    return list((Object)null);
  }

  public final List list(Object[] paramArrayOfObject)
    throws BasicException
  {
    return list(paramArrayOfObject);
  }

  public final List list(Object paramObject)
    throws BasicException
  {
    DataResultSet localDataResultSet = openExec(paramObject);
    List localList = fetchAll(localDataResultSet);
    localDataResultSet.close();
    closeExec();
    return localList;
  }

  public final List listPage(int paramInt1, int paramInt2)
    throws BasicException
  {
    return listPage(null, paramInt1, paramInt2);
  }

  public final List listPage(Object paramObject, int paramInt1, int paramInt2)
    throws BasicException
  {
    DataResultSet localDataResultSet = openExec(paramObject);
    List localList = fetchPage(localDataResultSet, paramInt1, paramInt2);
    localDataResultSet.close();
    closeExec();
    return localList;
  }

  public final Object find()
    throws BasicException
  {
    return find((Object)null);
  }

  public final Object find(Object[] paramArrayOfObject)
    throws BasicException
  {
    return find(paramArrayOfObject);
  }

  public final Object find(Object paramObject)
    throws BasicException
  {
	  //param ob=dbdaaa2f-30e9-497b-be3c-b5d5a151be30
    DataResultSet localDataResultSet = openExec(paramObject);
    Object localObject = fetchOne(localDataResultSet);
    localDataResultSet.close();
    closeExec();
    return localObject;
  }

  @SuppressWarnings("all")
public final List fetchAll(DataResultSet paramDataResultSet)
    throws BasicException
  {
    if (paramDataResultSet == null)
      throw new BasicException(LocalRes.getIntString("exception.nodataset"));
    ArrayList localArrayList = new ArrayList();
    while (paramDataResultSet.next()) {
		Object current = paramDataResultSet.getCurrent();
		localArrayList.add(current);
	}
    return localArrayList;
  }

  public final List fetchPage(DataResultSet paramDataResultSet, int paramInt1, int paramInt2)
    throws BasicException
  {
    if (paramDataResultSet == null)
      throw new BasicException(LocalRes.getIntString("exception.nodataset"));
    if ((paramInt1 < 0) || (paramInt2 < 0))
      throw new BasicException(LocalRes.getIntString("exception.nonegativelimits"));
    while ((paramInt1 > 0) && (paramDataResultSet.next()))
      paramInt1--;
    ArrayList localArrayList = new ArrayList();
    if (paramInt1 == 0)
      while ((paramInt2 > 0) && (paramDataResultSet.next()))
      {
        paramInt2--;
        localArrayList.add(paramDataResultSet.getCurrent());
      }
    return localArrayList;
  }

  public final Object fetchOne(DataResultSet paramDataResultSet)
    throws BasicException
  {
    if (paramDataResultSet == null)
      throw new BasicException(LocalRes.getIntString("exception.nodataset"));
    if (paramDataResultSet.next())
      return paramDataResultSet.getCurrent();
    return null;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.loader.BaseSentence
 * JD-Core Version:    0.6.0
 */